define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'knscy.users/index',
        add_url: 'knscy.users/add',
        edit_url: 'knscy.users/edit',
        delete_url: 'knscy.users/delete',
        export_url: 'knscy.users/export',
        modify_url: 'knscy.users/modify',
        password_url: 'knscy.users/password',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID'}, 
                    {field: 'mobile', search:true, title: '手机号码',minWidth:120},
                    {field: 'head_img', search:false, title: '头像',width:90, imageHeight: 25, templet: ea.table.image},
                    {field: 'nickname', title: '昵称',minWidth:90},
                    {field: 'username', title: '用户名',minWidth:90},
                    {field: 'ishexiao', search: 'select',width:100, selectList: ["否","是"], title: '核销员', templet: ea.table.switch},
                    {field: 'remark', title: '备注说明',minWidth:90, templet: ea.table.text},
                    {field: 'login_num', title: '登录次数',minWidth:90},
                    {field: 'last_login_ip', title: '上一次登录ip',minWidth:120},
                    {field: 'last_login_time', title: '最后登录时间',minWidth:200,search: 'range'},
                    {field: 'sort', title: '排序', edit: 'text',width:90,},
                    {field: 'status', search: 'select',width:90, selectList: ["禁用","启用"], title: '状态', templet: ea.table.switch},
                    {field: 'create_time', title: '创建时间',minWidth:120,search: 'range'},
                    {fixed:'right',width: 250, title: '操作', templet: ea.table.tool,
                     
                        operat: [
                            'edit',
                            [{
                                text: '设置密码',
                                url: init.password_url,
                                method: 'open',
                                auth: 'password',
                                class: 'layui-btn layui-btn-normal layui-btn-xs',
                            }],
                            'delete'
                        ]
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        password: function () {
            ea.listen();
        }
    };
    return Controller;
});